<?php
/**
 * 后台管理
 * @author jianhui
 *
 */
class Admin extends MY_Controller{
    function Admin(){
        parent::MY_Controller();
        $this->user['userRole'] == 6 || showError('您无法进入此页面');
        $tab = $this->input->get('tab');
        $this->viewData['tab'] = $tab ? $tab : 'index';
        //设置导航
        $this->navbarList[] = array('Admin','index', 'title'=>'后台管理');
        //主题
        //$this->theme = 'bootstrap';
        //面包屑
        $this->viewData['breadcrumb'][] = array('url'=>printUrl('Admin', 'index'),'title'=>'管理首页');
    }
    /**
     * 首页
     */
    function index(){
        $this->load->view('Admin/index', $this->viewData);
    }
    /**
     * 时段列表
     */
    function timeUnitList(){
        //年份
        $this->viewData['yearList'] = $this->timeUnitModel->getCacheData('yearList');
        $where = array();
        $year = $this->input->get('year');
        $where['year'] = $year ? $year : $this->config->item('nowYear');
        $this->viewData['year'] = $where['year'];
        $this->viewData['timeUnitList'] = $this->timeUnitModel->getList($where, '', '', '', 'orderNum asc,id asc');
        $this->load->view('Admin/timeUnitList', $this->viewData);
    }
    /**
     * 增加或修改时段
     */
    function timeUnitAdd(){
        if ($_POST){
            $id = $this->input->post('id');
            $data = array(
                'year'  => (int)$this->input->post('year'),
                'name'  => $this->input->post('name'),
                'orderNum'  => (int)$this->input->post('orderNum'),
                'startTime' => $this->input->post('startTime'),
                'endTime'   => $this->input->post('endTime'),
            );
            //单店时间设置
            $commonTimeSetting = $this->input->post('commonTime');
            //区域营销基金时间设置
            $areaTimeSetting = $this->input->post('areaTime');
            //车展基金
            $carTimeSetting = $this->input->post('carTime');
            //巡展基金
            $xunTimeSetting = $this->input->post('xunTime');
            //专项基金
            $specialTimeSetting = $this->input->post('specialTime');
            $data['year'] || showError('请输入年份');
            $data['year'] >= 2016 || showError('年份应大于或等于2016年');
            $data['name'] || showError('请输入时段名称');
            $data['orderNum'] || $data['orderNum'] = 0;
            $data['startTime'] || showError('请选择时段开始时间');
            $data['endTime'] || showError('请选择时段结束时间');
            date('d', strtotime($data['startTime'])) == 1 || showError('开始时间非当月第一天');
            //结束时间戳
            $endTime = strtotime($data['endTime']);
            date('d', $endTime) == date('t', $endTime) || showError('结束时间非当月最后一天');
            if ($this->timeUnitModel->getData(array('year'=>$data['year'],'name'=>$data['name'],'id !='=>$id))){
                showError('已存在同名时段');
            }
            //默认初始化时间
            //专营店有效基金预算申请开始时间默认为【时段开始前十天】
            $commonTimeSetting['budgetApplyStart'] || $commonTimeSetting['budgetApplyStart'] = date("Y-m-d H:i:s", strtotime($data['startTime'].' -10 day'));
            //专营店有效基金预算申请结束时间默认为【时段结束时间】            
            $commonTimeSetting['budgetApplyEnd'] || $commonTimeSetting['budgetApplyEnd'] = $data['endTime'];
            //专营店有效基金预算审核开始时间默认为【预算申报开始时间】
            $commonTimeSetting['budgetAuditStart'] || $commonTimeSetting['budgetAuditStart'] = $commonTimeSetting['budgetApplyStart'];
            //专营店有效基金预算审核结束时间默认为【时段结束后15日内】
            $commonTimeSetting['budgetAuditEnd'] || $commonTimeSetting['budgetAuditEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +15 day'));
            //专营店有效基金结算申报开始时间默认为【时段开始时间】
            $commonTimeSetting['settleApplyStart'] || $commonTimeSetting['settleApplyStart'] = $data['startTime'];
            //专营店有效基金结算申报结束时间默认为【时段结束后10日内】
            $commonTimeSetting['settleApplyEnd'] || $commonTimeSetting['settleApplyEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +10 day'));
            //专营店有效基金结算审核开始时间默认为【时段开始时间】
            $commonTimeSetting['settleAuditStart'] || $commonTimeSetting['settleAuditStart'] = $data['startTime'];
            //专营店有效基金结算审核结束时间默认为【时段结束后20天内】  
            $commonTimeSetting['settleAuditEnd'] || $commonTimeSetting['settleAuditEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //专营店有效基金结算评分开始时间默认为【时段开始时间】
            $commonTimeSetting['settleScoreStart'] || $commonTimeSetting['settleScoreStart'] = $data['startTime'];
            //专营店有效基金结算评分开始时间默认为【时段结束后20天内】
            $commonTimeSetting['settleScoreEnd'] || $commonTimeSetting['settleScoreEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //专营店有效基金金额修改开始时间
            $commonTimeSetting['settleChangeStart'] || $commonTimeSetting['settleChangeStart'] = $data['startTime'];
            //专营店有效基金金额修改结束时间
            $commonTimeSetting['settleChangeEnd'] || $commonTimeSetting['settleChangeEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +30 day'));
            //转换为json格式存进数据库
            $data['commonTimeSetting'] = serialize($commonTimeSetting);
            //区域营销基金预算申报开始时间默认为【时段开始前10天】
            $areaTimeSetting['budgetApplyStart'] || $areaTimeSetting['budgetApplyStart'] = date("Y-m-d H:i:s", strtotime($data['startTime'].' -10 day'));
            //区域营销基金预算申报结束时间默认为【时段结束时间】
            $areaTimeSetting['budgetApplyEnd'] || $areaTimeSetting['budgetApplyEnd'] = $data['endTime'];
            //区域营销基金预算审核开始时间默认为【时段开始时间】（区域营销基金没有预算审核）
            $areaTimeSetting['budgetAuditStart'] || $areaTimeSetting['budgetAuditStart'] = $data['startTime'];
            //区域营销基金预算审核结束时间默认为【时段结束时间】（区域营销基金没有预算审核）
            $areaTimeSetting['budgetAuditEnd'] || $areaTimeSetting['budgetAuditEnd'] = $data['endTime'];
            //区域营销基金结算申报开始时间默认为【时段开始时间】
            $areaTimeSetting['settleApplyStart'] || $areaTimeSetting['settleApplyStart'] = $data['startTime'];
            //区域营销基金结算申报结束时间默认为【时段结束后10天内】
            $areaTimeSetting['settleApplyEnd'] || $areaTimeSetting['settleApplyEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +10 day'));
            //区域营销基金结算审核开始时间默认为【时段开始时间】
            $areaTimeSetting['settleAuditStart'] || $areaTimeSetting['settleAuditStart'] = $data['startTime'];
            //区域营销基金结算审核结束时间默认为【时段结束后20天内】
            $areaTimeSetting['settleAuditEnd'] || $areaTimeSetting['settleAuditEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //区域营销基金评分开始时间默认为【时段开始时间】
            $areaTimeSetting['settleScoreStart'] || $areaTimeSetting['settleScoreStart'] = $data['startTime'];
            //区域营销基金评分结束时间默认为【时段结束后20天内】
            $areaTimeSetting['settleScoreEnd'] || $areaTimeSetting['settleScoreEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //区域营销基金金额修改开始时间
            $areaTimeSetting['settleChangeStart'] || $areaTimeSetting['settleChangeStart'] = $data['startTime'];
            //区域营销基金金额修改结束时间
            $areaTimeSetting['settleChangeEnd'] || $areaTimeSetting['settleChangeEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +30 day'));
            //转换为json格式存进数据库
            $data['areaTimeSetting'] = serialize($areaTimeSetting);
            //车展基金预算申报开始时间默认为【时段开始前10天】
            $carTimeSetting['budgetApplyStart'] || $carTimeSetting['budgetApplyStart'] = date("Y-m-d H:i:s", strtotime($data['startTime'].' -10 day'));
            //车展基金预算申报结束时间默认为【时段结束时间】
            $carTimeSetting['budgetApplyEnd'] || $carTimeSetting['budgetApplyEnd'] = $data['endTime'];
            //车展基金预算审核开始时间默认为【时段开始时间】（车展基金没有预算审核）
            $carTimeSetting['budgetAuditStart'] || $carTimeSetting['budgetAuditStart'] = $data['startTime'];
            //车展基金预算审核结束时间默认为【时段结束时间】（车展基金没有预算审核）
            $carTimeSetting['budgetAuditEnd'] || $carTimeSetting['budgetAuditEnd'] = $data['endTime'];
            //车展基金结算申报开始时间默认为【时段开始时间】
            $carTimeSetting['settleApplyStart'] || $carTimeSetting['settleApplyStart'] = $data['startTime'];
            //车展基金结算申报结束时间默认为【时段结束后10天内】
            $carTimeSetting['settleApplyEnd'] || $carTimeSetting['settleApplyEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +10 day'));
            //车展基金结算审核开始时间默认为【时段开始时间】
            $carTimeSetting['settleAuditStart'] || $carTimeSetting['settleAuditStart'] = $data['startTime'];
            //车展基金结算审核结束时间默认为【时段结束后20天内】
            $carTimeSetting['settleAuditEnd'] || $carTimeSetting['settleAuditEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //车展基金评分开始时间默认为【时段开始时间】
            $carTimeSetting['settleScoreStart'] || $carTimeSetting['settleScoreStart'] = $data['startTime'];
            //车展基金评分结束时间默认为【时段结束后20天内】
            $carTimeSetting['settleScoreEnd'] || $carTimeSetting['settleScoreEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //车展基金金额修改开始时间
            $carTimeSetting['settleChangeStart'] || $carTimeSetting['settleChangeStart'] = $data['startTime'];
            //车展基金金额修改结束时间
            $carTimeSetting['settleChangeEnd'] || $carTimeSetting['settleChangeEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +30 day'));
            //转换为json格式存进数据库
            $data['carTimeSetting'] = serialize($carTimeSetting);
            //巡展基金预算申报开始时间默认为【时段开始前10天】
            $xunTimeSetting['budgetApplyStart'] || $xunTimeSetting['budgetApplyStart'] = date("Y-m-d H:i:s", strtotime($data['startTime'].' -10 day'));
            //巡展基金预算申报结束时间默认为【时段结束时间】
            $xunTimeSetting['budgetApplyEnd'] || $xunTimeSetting['budgetApplyEnd'] = $data['endTime'];
            //巡展基金预算审核开始时间默认为【时段开始时间】（巡展基金没有预算审核）
            $xunTimeSetting['budgetAuditStart'] || $xunTimeSetting['budgetAuditStart'] = $data['startTime'];
            //巡展基金预算审核结束时间默认为【时段结束时间】（巡展基金没有预算审核）
            $xunTimeSetting['budgetAuditEnd'] || $xunTimeSetting['budgetAuditEnd'] = $data['endTime'];
            //巡展基金结算申报开始时间默认为【时段开始时间】
            $xunTimeSetting['settleApplyStart'] || $xunTimeSetting['settleApplyStart'] = $data['startTime'];
            //巡展基金结算申报结束时间默认为【时段结束后10天内】
            $xunTimeSetting['settleApplyEnd'] || $xunTimeSetting['settleApplyEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +10 day'));
            //巡展基金结算审核开始时间默认为【时段开始时间】
            $xunTimeSetting['settleAuditStart'] || $xunTimeSetting['settleAuditStart'] = $data['startTime'];
            //巡展基金结算审核结束时间默认为【时段结束后20天内】
            $xunTimeSetting['settleAuditEnd'] || $xunTimeSetting['settleAuditEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //巡展基金评分开始时间默认为【时段开始时间】
            $xunTimeSetting['settleScoreStart'] || $xunTimeSetting['settleScoreStart'] = $data['startTime'];
            //巡展基金评分结束时间默认为【时段结束后20天内】
            $xunTimeSetting['settleScoreEnd'] || $xunTimeSetting['settleScoreEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //巡展基金金额修改开始时间
            $xunTimeSetting['settleChangeStart'] || $xunTimeSetting['settleChangeStart'] = $data['startTime'];
            //巡展基金金额修改结束时间
            $xunTimeSetting['settleChangeEnd'] || $xunTimeSetting['settleChangeEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +30 day'));
            //转换为json格式存进数据库
            $data['xunTimeSetting'] = serialize($xunTimeSetting);
            //专项基金预算申报开始时间默认为【时段开始前10天】
            $specialTimeSetting['budgetApplyStart'] || $specialTimeSetting['budgetApplyStart'] = date("Y-m-d H:i:s", strtotime($data['startTime'].' -10 day'));
            //专项基金预算申报结束时间默认为【时段结束时间】
            $specialTimeSetting['budgetApplyEnd'] || $specialTimeSetting['budgetApplyEnd'] = $data['endTime'];
            //专项基金预算审核开始时间默认为【时段开始时间】（专项基金没有预算审核）
            $specialTimeSetting['budgetAuditStart'] || $specialTimeSetting['budgetAuditStart'] = $data['startTime'];
            //专项基金预算审核结束时间默认为【时段结束时间】（专项基金没有预算审核）
            $specialTimeSetting['budgetAuditEnd'] || $specialTimeSetting['budgetAuditEnd'] = $data['endTime'];
            //专项基金结算申报开始时间默认为【时段开始时间】
            $specialTimeSetting['settleApplyStart'] || $specialTimeSetting['settleApplyStart'] = $data['startTime'];
            //专项基金结算申报结束时间默认为【时段结束后10天内】
            $specialTimeSetting['settleApplyEnd'] || $specialTimeSetting['settleApplyEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +10 day'));
            //专项基金结算审核开始时间默认为【时段开始时间】
            $specialTimeSetting['settleAuditStart'] || $specialTimeSetting['settleAuditStart'] = $data['startTime'];
            //专项基金结算审核结束时间默认为【时段结束后20天内】
            $specialTimeSetting['settleAuditEnd'] || $specialTimeSetting['settleAuditEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //专项基金评分开始时间默认为【时段开始时间】
            $specialTimeSetting['settleScoreStart'] || $specialTimeSetting['settleScoreStart'] = $data['startTime'];
            //专项基金评分结束时间默认为【时段结束后20天内】
            $specialTimeSetting['settleScoreEnd'] || $specialTimeSetting['settleScoreEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +20 day'));
            //专项基金金额修改开始时间
            $specialTimeSetting['settleChangeStart'] || $specialTimeSetting['settleChangeStart'] = $data['startTime'];
            //专项基金金额修改结束时间
            $specialTimeSetting['settleChangeEnd'] || $specialTimeSetting['settleChangeEnd'] = date("Y-m-d H:i:s", strtotime($data['endTime'].' +30 day'));
            //转换为json格式存进数据库
            $data['specialTimeSetting'] = serialize($specialTimeSetting);
            if ($id){
                $timeId = $this->timeUnitModel->edit($id, $data);
            }else{
                $timeId = $this->timeUnitModel->add($data);
            }
            if ($timeId){
                $this->timeUnitModel->createTimeUnitCache();
                showSuccess('时段保存成功');
            }else{
                showError('时段保存失败');
            }
        }else{
            $this->theme = 'bootstrap';
            $id = (int)$this->input->get('id');
            if ($id){
                $this->viewData['timeUnitData'] = $this->timeUnitModel->getNewData($id);
                $this->viewData['timeUnitData'] || showError('数据不存在');
            }
            $this->load->view('Admin/timeUnitAdd', $this->viewData);
        }
    }
    /**
     * 数据重建
     */
    function rebuild(){
        $runing = (int)$this->input->get('runing');
        if ($runing == 1){
            $dataType = $this->input->get('dataType');
            $year = (int)$this->input->get('year');
            $timeUnit = (int)$this->input->get('timeUnit');
            $page = (int)$this->input->get('page');
            $page || $page = 1;
            $pageSize = 50;
            //条件ID
            $idsData = $this->input->get('ids');
            $ids = array();
            if ($idsData){
                $idsData = str_replace('，', ',', $idsData);
                if (strpos($idsData, ',') !== false){
                    $idsData = explode(',', $idsData);
                    foreach ($idsData as $v){
                        $ids[] = (int)$v;
                    }
                }else{
                    $ids[] = (int)$idsData;
                }
            }
            $where = array('year'=>$year,'timeUnit'=>$timeUnit);
            if ((int)$dataType[0] == 1){//专营店营销基金
                if((int)$dataType == 11 && $ids){
                    $where['id'] = array('in', $ids);
                }
                $this->load->model('commonProcessModel');
                $procList = $this->commonProcessModel->getList($where);
            }elseif ((int)$dataType[0] == 2){//区域营销基金
                if((int)$dataType == 21 && $ids){
                    $where['id'] = array('in', $ids);
                }
                $this->load->model('areaProcessModel');
                $procList = $this->areaProcessModel->getList($where);
            }elseif ((int)$dataType[0] == 3){//车展基金
                if ((int)$dataType == 31 && $ids){
                    $where['id'] = array('in', $ids);
                }
                $this->load->model('carProcessModel');
                $procList = $this->carProcessModel->getList($where);
            }elseif ((int)$dataType[0] == 4){//巡展基金
                if ((int)$dataType == 41 && $ids){
                    $where['id'] = array('in', $ids);
                }
                $this->load->model('xunProcessModel');
                $procList = $this->xunProcessModel->getList($where);
            }elseif ((int)$dataType[0] == 5){//专项基金
                unset($where['timeUnit']);
                if ((int)$dataType == 51 && $ids){
                    $where['id'] = array('in', $ids);
                }
                $this->load->model('specialProcessModel');
                $procList = $this->specialProcessModel->getList($where);
            }
            $procIds = array_keys($procList);
            $childWhere = array('procId'=>array('in',$procIds));
            $ids && $childWhere['id'] = array('in', $ids);
            $count = 0;
            switch ((int)$dataType){
                case 11://单店基金汇总金额
                    foreach ($procIds as $v){
                        $this->commonProcessModel->updateMoney($v);
                        echo '专营店营销基金汇总金额]:ID为：'.$v.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    break;
                case 12://专营店营销基金-广宣传播金额
                    $this->load->model('commonOnlineModel');
                    $list = $this->commonOnlineModel->getList($childWhere, $pageSize, ($page-1)*$pageSize,'', 'id asc');
                    foreach ($list as $k => $v){
                        $this->commonOnlineModel->updateMoney($k);
                        echo '更新[专营店营销基金-广宣传播金额]:ID为：'.$k.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    $count = count($list);
                    break;
                case 13: //专营店营销基金-营销活动金额
                    $this->load->model('commonOfflineModel');
                    $list = $this->commonOfflineModel->getList($childWhere, $pageSize, ($page-1)*$pageSize,'', 'id asc');
                    foreach ($list as $k => $v){
                        $this->commonOfflineModel->updateMoney($k);
                        echo '更新[专营店营销基金-营销活动金额]:ID为：'.$k.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    $count = count($list);
                    break;
                case 21: //区域营销基金汇总金额
                    foreach ($procIds as $v){
                        $this->areaProcessModel->updateMoney($v);
                        echo '更新[区域营销基金汇总金额]:ID为：'.$v.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    break;
                case 22: //区域营销基金-广宣传播金额
                    $this->load->model('areaOnlineModel');
                    $list = $this->areaOnlineModel->getList($childWhere, $pageSize, ($page-1)*$pageSize,'', 'id asc');
                    foreach ($list as $k => $v){
                        $this->areaOnlineModel->updateMoney($k);
                        echo '更新[区域营销基金-广宣传播金额]:ID为：'.$k.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    $count = count($list);
                    break;
                case 23: //区域营销基金-营销活动金额
                    $this->load->model('areaOfflineModel');
                    $list = $this->areaOfflineModel->getList($childWhere, $pageSize, ($page-1)*$pageSize,'', 'id asc');
                    foreach ($list as $k => $v){
                        $this->areaOfflineModel->updateMoney($k);
                        echo '更新[区域营销基金-营销活动金额]:ID为：'.$k.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    $count = count($list);
                    break;
                case 31: //车展基金汇总金额
                    foreach ($procIds as $k => $v){
                        $this->carProcessModel->updateMoney($v);
                        echo '更新[车展基金汇总金额]:ID为：'.$v.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    break;
                case 32: //车展基金地方-项目金额
                    $this->load->model('carProjectModel');
                    $list = $this->carProjectModel->getList($childWhere, $pageSize, ($page-1)*$pageSize,'', 'id asc');
                    foreach ($list as $k => $v){
                        $this->carProjectModel->updateMoney($k);
                        echo '更新[车展基金地方-项目金额]:ID为：'.$k.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    $count = count($list);
                    break;
                case 41: //巡展基金汇总金额
                    foreach ($procIds as $k => $v){
                        $this->xunProcessModel->updateMoney($v);
                        echo '更新[巡展基金汇总金额]:ID为：'.$v.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    break;
                case 42://车展基金地方-项目金额
                    $this->load->model('xunProjectModel');
                    $list = $this->xunProjectModel->getList($childWhere, $pageSize, ($page-1)*$pageSize,'', 'id asc');
                    foreach ($list as $k => $v){
                        $this->xunProjectModel->updateMoney($k);
                        echo '更新[车展基金地方-项目金额]:活动项目ID为：'.$k.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    $count = count($list);
                    break;
                case 51://专项基金汇总金额
                    foreach ($procIds as $k => $v){
                        $this->specialProcessModel->updateMoney($v);
                        echo '更新[专项基金汇总金额]:ID为：'.$v.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    break;
                case 52: //专项基金-广宣传播基金
                    $this->load->model('specialOnlineModel');
                    $list = $this->specialOnlineModel->getList($childWhere, $pageSize, ($page-1)*$pageSize,'', 'id asc');
                    foreach ($list as $k => $v){
                        $this->specialOnlineModel->updateMoney($k);
                        echo '更新[专项基金-广宣传播基金]:ID为：'.$k.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    $count = count($list);
                    break;
                case 53: //专项基金-营销活动
                    $this->load->model('specialOnlineModel');
                    $list = $this->specialOnlineModel->getList($childWhere, $pageSize, ($page-1)*$pageSize,'', 'id asc');
                    foreach ($list as $k => $v){
                        $this->specialOnlineModel->updateMoney($k);
                        echo '更新[专项基金-营销活动]:ID为：'.$k.'的金额成功<br>';
                        echo str_repeat(" ",4096);
                    }
                    $count = count($list);
                    break;
                default:
                    showError('无效类别');
            }
            if ($count < $pageSize){
                echo "全部执行完成";
            }else{
                unset($_GET['c'],$_GET['m']);
                $_GET['page'] = $page + 1;
                echo '<script language="javascript" type="text/javascript">
                           window.location.href="'.printUrl('Admin','rebuild', $_GET).'"; 
                    </script>';
            }
            //showSuccess('执行成功,成功计算条数：'.$ok);
        }else{
            $dataTypeCon = array(
                11 => '专营店营销基金汇总金额', 12 => '专营店营销基金-广宣传播金额', 13 =>'专营店营销基金-营销活动金额',
                21 => '区域营销基金汇总金额', 22 => '区域营销基金-广宣传播金额',23 => '区域营销基金-营销活动金额',
                31 => '车展基金汇总金额', 32 => '车展基金地方-项目金额',
                41 => '巡展基金汇总金额', 42 => '巡展基金-项目金额',
                51 => '专项基金汇总金额', 52 => '专项基金-广宣传播金额',53 => '专项基金-营销活动金额',
            );
            $this->viewData['dataTypeCon'] = $dataTypeCon;
            $this->viewData['year'] = $this->config->item('nowYear');
            $this->load->view('Admin/rebuild', $this->viewData);
        }
    }
}